/**
 * Created with JetBrains WebStorm.
 * User: daqing
 * Date: 13-8-23
 * Time: 下午1:38
 * To change this template use File | Settings | File Templates.
 */


var username1 = '6280140@qq.com';
var password1 = '111111';
var username2 = 'secretsundaqing@126.com';
var password2 = 'sundaqing';
var fs = require('fs');
var util = require('util');
var gokuai = require('./gokuai');
var clientId = '1047ed884922dc4651b39840c548a680';
var clientSecret = '1ff2b33c837032d333dd6a870689a87d';
var client1 = new gokuai.app({username:username1,password:password1,clientId:clientId,clientSecret:clientSecret,machine:'webdav'});
//var client2 = new gokuai.app({username:username2,password:password2,machine:'webdav'});

client1.login(function(err,msg){
//    if(!err){
//        var command = client2.command();
//        command.createReadStream(null,null,'IMG_7782.JPG',function(err,stream){
//            stream.pipe(fs.createWriteStream('122.jpg'));
//        });
//    }else{
//        console.log('err:',err);
//    }

    if(!err){
        var command = client1.command();
//        command.version('Wireshark-win64-1.10.1.exe',function(err,data){
//           if(!err){
//               console.log('data:'+util.inspect(data));
//               client1.command().revert('Wireshark-win64-1.10.1.exe',342,function(err){
//                   if(err){
//                       console.log('err:'+err);
//                   }
//               }) ;
//           }
//        });

        command.search('Wireshark',0,function(err,result){
            if(!err){
                console.log('result:'+util.inspect(result));
            }else{
                console.log('err:'+err);
            }
        });
    }

});
var download = function(command,cb){
    command.createReadStream(null,null,'Wireshark-win64-1.10.1.exe',function(err,stream){
        stream.pipe(fs.createWriteStream('111'));
        cb(err,'Wireshark-win64-1.10.1.exe');
    });
}

var version = function(command,cb){
    command.version('Wireshark-win64-1.10.1.exe',function(err,data){
        cb(err,data);
    });
}

var search = function(command,cb){
    command.search('Wireshark',0,function(err,result){
        if(!err){
            console.log('result:'+util.inspect(result));
        }else{
            console.log('err:'+err);
        }
        cb(err);
    });
}

var metadata = function(command,cb){
    command.metadata('测试/1/',function(err,result){
        if(!err){
            console.log('result:'+util.inspect(result));
        }else{
            console.log('err:'+err);
        }
        cb(err);
    });
}
var request = require("request");

var args = {
    "method": "GET",
    "url": "http://www.qq.com",
    "socks5":"127.0.0.1:1080"
};

//request(args, function(err, res, data){
//   console.log(data);
//});

var should = require('should');

var user = {
    name: 'tj'
    , pets: ['tobi', 'loki', 'jane', 'bandit']
};

user.should.have.property('name', 'tj');
user.should.have.property('pets').with.lengthOf(4);

// or without Object.prototype, for guys how did Object.create(null)
should(user).have.property('name', 'tj');
should(true).ok;

//someAsyncTask(user, function(err, result){
//    should.not.exist(err);
//    should.exist(result);
//    result.bar.should.equal(foo);
//});